package com.liming.web.controller;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.liming.service.impl.BookServiceImpl;
import com.liming.utils.DBUtils;

public class AdmLogin extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username=request.getParameter("adminname");
		String sql="select * from Administrator where A_id=\'"+username+"\'";
		System.out.println(sql);
		Connection conn=DBUtils.open();
		try {
			Statement sa=conn.createStatement();
			ResultSet rs=sa.executeQuery(sql);
			if(rs.next()){
				request.getSession().setAttribute("admin", username);
				System.out.println("admin");
				response.sendRedirect(request.getContextPath()+"/servlet/GetCaigouBook");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);

	}

}
